
function prepend( source , maxLength , fillString ){
    // 将 String 当作普通函数使用时，用于将 其它值 转化为 string 值
    let str = String(source);
    str = str.padStart( maxLength , fillString );
    return str ;
}

function DateTime(){

    let now = new Date();
    
    let year = now.getFullYear();
    // 洋鬼子那边的月份是从零开始计数的
    let mon = now.getMonth() + 1 ;
    mon = prepend( mon , 2 , '0' );
    let date = now.getDate();
    date = prepend( date , 2 , '0' );

    let hour = now.getHours();
    hour = prepend( hour , 2 , '0' );
    
    let min = now.getMinutes();
    min = prepend( min , 2 , '0' );
    
    let sec = now.getSeconds();
    sec = prepend( sec , 2 , '0' );

    let ms = now.getMilliseconds();
    ms = prepend( ms , 3 , '0' );

    let str = `${year}年${mon}月${date}日 ${hour}:${min}:${sec}.${ms}`;

    return (<div>{ str }</div>)
}

export default DateTime ;